/*
 * @Description: 用户模型
 * @Version: 1.0
 * @Autor: JiaJun Wu
 * @Date: 2021-09-14 14:23:57
 * @LastEditors: JiaJun Wu
 * @LastEditTime: 2021-09-24 17:56:49
 */
use super::*;

/// 输出的参数
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
#[serde(crate = "rocket::serde")]
pub struct UserModel {
    // #[serde(deserialize_with = "deserialize_object_id")]
    #[serde(serialize_with = "serialize_object_id", rename = "_id")]
    pub id: Option<ObjectId>,
    /// 用户名
    #[serde(serialize_with = "serialize_string")]
    pub username: Option<String>,
    /// 密码
    #[serde(serialize_with = "serialize_string")]
    pub password: Option<String>,
    /// 真实姓名
    #[serde(serialize_with = "serialize_string")]
    pub realname: Option<String>,
    /// 出生年
    #[serde(serialize_with = "serialize_i32", rename = "birthYear")]
    pub birth_year: Option<i32>,
    /// 出生月
    #[serde(serialize_with = "serialize_i32", rename = "birthMonth")]
    pub birth_month: Option<i32>,
    /// 出生日
    #[serde(serialize_with = "serialize_i32", rename = "birthDay")]
    pub birth_day: Option<i32>,
    /// 性别 0.女 1.男 3.保密
    #[serde(serialize_with = "serialize_i32")]
    pub sex: Option<i32>,
    /// 机构id
    #[serde(serialize_with = "serialize_object_id", rename = "orgId")]
    pub org_id: Option<ObjectId>,
    /// 机构名称
    #[serde(serialize_with = "serialize_string", rename = "orgName")]
    pub org_name: Option<String>,
    /// 用户类型 1.管理员 2.普通用户 3.其他
    #[serde(serialize_with = "serialize_i32")]
    pub types: Option<i32>,
    /// 描述/备注
    #[serde(serialize_with = "serialize_string")]
    pub desc: Option<String>,
    #[serde(serialize_with = "serialize_string")]
    pub qq: Option<String>,
    /// 手机号码
    #[serde(serialize_with = "serialize_string")]
    pub phone: Option<String>,
    /// 电子邮箱
    #[serde(serialize_with = "serialize_string")]
    pub email: Option<String>,
    /// 用户状态 1.正常，2.禁用，3.注销
    #[serde(serialize_with = "serialize_i32")]
    pub enabled: Option<i32>,
    /// 头像id
    #[serde(serialize_with = "serialize_object_id")]
    pub portrait: Option<ObjectId>,
    /// 积累登陆次数
    #[serde(serialize_with = "serialize_i32", rename = "totalLoginCount")]
    pub total_login_count: Option<i32>,
    /// 累计登录错误次数，超过最高次数，将限制登录
    #[serde(serialize_with = "serialize_i32", rename = "totalLoginFailure")]
    pub total_login_failure: Option<i32>,
    /// 上次登陆ip
    #[serde(serialize_with = "serialize_ip", rename = "lastLoginIp")]
    pub last_login_ip: Option<i64>,
    /// 上次登陆时间
    #[serde(serialize_with = "serialize_date", rename = "lastLoginTime")]
    pub last_login_time: Option<i64>,
    // /// 创建时间
    // #[serde(serialize_with = "serialize_date", rename = "createTime")]
    // pub create_time: Option<i64>,
    /// 修改时间
    #[serde(serialize_with = "serialize_date", rename = "updateTime")]
    pub update_time: Option<i64>,
    /// 修改人
    #[serde(serialize_with = "serialize_object_id", rename = "updateBy")]
    pub update_by: Option<ObjectId>,
}
